/*
 * serial.h
 *
 * Created: 3/27/2011 09:57:33
 *  Author: morpheus
 */ 


#ifndef SERIAL_H_
#define SERIAL_H_
#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/pgmspace.h>
#include <avr/portpins.h>

#define USART_BAUDRATE 9600 
#define BAUD_PRESCALE (((F_CPU / (USART_BAUDRATE * 16UL))) - 1)

/** Set the baud rate  */
//#define BAUD 9600 
//#include <util/setbaud.h>

/** Size of the circular receive buffer, must be power of 2 */
#ifndef UART_RX_BUFFER_SIZE
#define UART_RX_BUFFER_SIZE 32
#endif

/** Size of the circular transmit buffer, must be power of 2 */
#ifndef UART_TX_BUFFER_SIZE
#define UART_TX_BUFFER_SIZE 32
#endif

/* test if the size of the circular buffers fits into SRAM */
/*#if ( (UART_RX_BUFFER_SIZE+UART_TX_BUFFER_SIZE) >= (RAMEND-0x60 ) )
#error "size of UART_RX_BUFFER_SIZE + UART_TX_BUFFER_SIZE larger than size of SRAM"
#endif*/

void uart_init();
unsigned char uart_receive( void );
void uart_putc(const char data );
void uart_puts(const char *message);
void uart_puts_p(const char *progmem_s);

#endif /* SERIAL_H_ */
